Skip to content

bugfix(registry): Prioritize HKEY_CURRENT_USER registry reads and writes over HKEY_LOCAL_MACHINE to prevent inaccessible data#1844

Merged
xezon merged 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/fix-registry-hkcu-priority
Feb 25, 2026
Merged

bugfix(registry): Prioritize HKEY_CURRENT_USER registry reads and writes over HKEY_LOCAL_MACHINE to prevent inaccessible data#1844
xezon merged 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/fix-registry-hkcu-priority

Conversation

@bobtista

@bobtista bobtista commented Nov 13, 2025

Copy link
Copy Markdown

Per-user settings (e.g. HTTP Proxy) should always go in HKEY_CURRENT_USER.

Flips both read and write priority to prefer HKCU over HKLM across all registry helpers, with HKLM as fallback. This prevents stale HKCU values when the game is run with admin privileges.

@bobtista bobtista marked this pull request as ready for review December 3, 2025 18:03
@Skyaero42

Copy link
Copy Markdown

Imagine the following:

  • I install the game (e.g. through Steam) for windows user1
  • I play the game (key is in CURRENT_USER)
  • I login as user2 in windows
  • I start the game.

could this be an issue, or is there a key generated for user2 as well?

@bobtista

Copy link
Copy Markdown
Author

Imagine the following:

  • I install the game (e.g. through Steam) for windows user1
  • I play the game (key is in CURRENT_USER)
  • I login as user2 in windows
  • I start the game.

could this be an issue, or is there a key generated for user2 as well?

Ok changed it so:
Reads (HKCU → HKLM): Users can override machine-wide defaults; if no user override exists, fall back to the shared value.
Writes (HKLM → HKCU): Preserves the original behavior—try global first, then per-user if needed.

This is good enough for this issue/change IMHO - Eventually, we should probably have intentional “is this setting global or per-user?” code in the game logic rather than relying on whether the user ran the game as admin or not.

Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Jan 26, 2026
@greptile-apps

greptile-apps Bot commented Feb 16, 2026

Copy link
Copy Markdown

Greptile Summary

Flipped registry read and write priority to prefer HKEY_CURRENT_USER over HKEY_LOCAL_MACHINE across all registry helpers, resolving per-user settings conflicts when running with admin privileges.

  • Read operations now check HKCU first, falling back to HKLM
  • Write operations now only write to HKCU (removed HKLM writes entirely in WWVegas)
  • Consistent behavior across all three registry implementations (WWVegas, Generals, GeneralsMD)
  • Prevents stale HKCU values from being overridden by HKLM when game runs elevated

Confidence Score: 5/5

  • Safe to merge - straightforward registry priority fix with correct Windows best practices
  • Changes are minimal, well-commented, and follow Windows registry conventions for per-user settings. Logic is sound: HKCU takes priority for reads and is the sole target for writes, preventing admin privilege conflicts.
  • No files require special attention

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WWDownload/registry.cpp Flipped read priority to HKCU-first and removed HKLM writes, now writing only to HKCU for per-user settings
Generals/Code/GameEngine/Source/Common/System/registry.cpp Flipped read priority to prefer HKCU over HKLM (no write functions in this file)
GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp Flipped read priority to prefer HKCU over HKLM for both Zero Hour and vanilla Generals registry paths

Last reviewed commit: 5844d2d

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp Outdated
Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp Outdated
Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp Outdated

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
Comment thread Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
@xezon xezon changed the title fix(registry): prioritize HKEY_CURRENT_USER over HKEY_LOCAL_MACHINE bugfix(registry): Prioritize HKEY_CURRENT_USER registry reads and writes over HKEY_LOCAL_MACHINE to prevent inaccessible data Feb 24, 2026
@xezon xezon merged commit b1c456b into TheSuperHackers:main Feb 25, 2026
25 checks passed
CookieLandProjects pushed a commit to CookieLandProjects/CLP_AI that referenced this pull request Feb 28, 2026
…tes over HKEY_LOCAL_MACHINE to prevent inaccessible data (TheSuperHackers#1844)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetStringFromRegistry can fail to read from the correct registry location depending on process admin privileges

3 participants